<?php

namespace app\api\controller\v5;

use \app\check\controller\Check;
use app\common\model\AstroSetting;
use think\Cache;
use \think\Db;
use \app\common\lib\exception\ApiException;

class Astroset extends Check
{
    public $charts = ['now', 'natal', 'transits', 'thirdprogressed', 'thirdprogressedvsnatal', 'progressions', 'progressionsvsnatal', 'solar', 'firdaria', 'profection', 'synastry', 'composite', 'composite_thirdprogressed', 'composite_progressions', 'davison', 'solar_return', 'lunar_return', 'marks', 'divination'];
    public $setting1 = [
        'now' => [
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'natal' => [
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100100001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'transits' => [
            'asp_orb_all' => [0 => 2, 60 => 1, 90 => 2, 120 => 2, 180 => 2, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
            'style' => 'cn',
            'firdaria' => 'default',
        ],
        'thirdprogressed' => [
            //            'asp_orb_all'=> [0=>3,60=>2,90=>3,120=>3,180=>3,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'thirdprogressedvsnatal' => [
            'asp_orb_all' => [0 => 2, 60 => 1, 90 => 2, 120 => 2, 180 => 2, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
            'style' => 'cn',
            'firdaria' => 'default',
        ],
        'progressions' => [
            //            'asp_orb_all'=> [0=>2,60=>2,90=>2,120=>2,180=>2,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'progressionsvsnatal' => [
            'asp_orb_all' => [0 => 2, 60 => 1, 90 => 2, 120 => 2, 180 => 2, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
            'style' => 'cn',
            'firdaria' => 'default',
        ],
        'solar' => [
            'asp_orb_all' => [0 => 1, 60 => 0, 90 => 1, 120 => 0, 180 => 1, 30 => 0, 150 => 1, 45 => 1, 135 => 1, 72 => 0, 144 => 0],
            'asps_display' => [0, 45, 90, 135, 180],
            'planets_display' => '111111111100100001111',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'solar_return' => [
            //            'asp_orb_all'=> [0=>8,60=>6,90=>7,120=>7,180=>7,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100100001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'lunar_return' => [
            //            'asp_orb_all'=> [0=>4,60=>2,90=>3,120=>3,180=>3.5,30=>0.5,150=>1,45=>1,135=>1,72=>0.5,144=>0.5],
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100100001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'firdaria' => [
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100100001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
            'firdaria' => 'default',
        ],
        'profection' => [
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100100001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'synastry' => [
            'asp_orb_all' => [0 => 6, 60 => 4, 90 => 6, 120 => 6, 180 => 6, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100100001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'composite' => [
            //            'asp_orb_all'=> [0=>4,60=>3,90=>4,120=>4,180=>4,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'composite_thirdprogressed' => [
            //            'asp_orb_all'=> [0=>5,60=>4,90=>5,120=>5,180=>5,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'composite_progressions' => [
            //            'asp_orb_all'=> [0=>4,60=>3,90=>4,120=>4,180=>4,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
            'style' => 'cn',
        ],
        'davison' => [
            //            'asp_orb_all'=> [0=>6,60=>5,90=>6,120=>6,180=>6,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'marks' => [
            //            'asp_orb_all'=> [0=>6,60=>5,90=>6,120=>6,180=>6,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'divination' => [
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
    ];
    public $setting2 = [
        'now' => [
            'asp_orb_all' => [0 => 4, 60 => 2, 90 => 3, 120 => 3, 180 => 3.5, 30 => 0.5, 150 => 1, 45 => 1, 135 => 1, 72 => 0.5, 144 => 0.5],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [3, 2.5, 1, 1, 1, 1.5, 1.5, 1, 1, 0.5],
            'h_sys' => 'p',
        ],
        'natal' => [
            'asp_orb_all' => [0 => 4, 60 => 2, 90 => 3, 120 => 3, 180 => 3.5, 30 => 0.5, 150 => 1, 45 => 1, 135 => 1, 72 => 0.5, 144 => 0.5],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [3, 2.5, 1, 1, 1, 1.5, 1.5, 1, 1, 0.5],
            'h_sys' => 'p',
        ],
        'transits' => [
            'asp_orb_all' => [0 => 2, 60 => 1, 90 => 2, 120 => 2, 180 => 2, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'thirdprogressed' => [
            'asp_orb_all' => [0 => 3, 60 => 2, 90 => 3, 120 => 3, 180 => 3, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'thirdprogressedvsnatal' => [
            'asp_orb_all' => [0 => 2, 60 => 1, 90 => 2, 120 => 2, 180 => 2, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'progressions' => [
            'asp_orb_all' => [0 => 2, 60 => 2, 90 => 2, 120 => 2, 180 => 2, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'progressionsvsnatal' => [
            'asp_orb_all' => [0 => 2, 60 => 1, 90 => 2, 120 => 2, 180 => 2, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'solar' => [
            'asp_orb_all' => [0 => 1, 60 => 0, 90 => 1, 120 => 0, 180 => 1, 30 => 0, 150 => 1, 45 => 1, 135 => 1, 72 => 0, 144 => 0],
            'asps_display' => [0, 45, 90, 135, 180],
            'planets_display' => '111111111100100001111',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'solar_return' => [
            'asp_orb_all' => [0 => 4, 60 => 2, 90 => 3, 120 => 3, 180 => 3.5, 30 => 0.5, 150 => 1, 45 => 1, 135 => 1, 72 => 0.5, 144 => 0.5],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [3, 2.5, 1, 1, 1, 1.5, 1.5, 1, 1, 0.5],
            'h_sys' => 'p',
        ],
        'lunar_return' => [
            'asp_orb_all' => [0 => 4, 60 => 2, 90 => 3, 120 => 3, 180 => 3.5, 30 => 0.5, 150 => 1, 45 => 1, 135 => 1, 72 => 0.5, 144 => 0.5],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100100001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'firdaria' => [
            'asp_orb_all' => [0 => 4, 60 => 2, 90 => 3, 120 => 3, 180 => 3.5, 30 => 0.5, 150 => 1, 45 => 1, 135 => 1, 72 => 0.5, 144 => 0.5],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [3, 2.5, 1, 1, 1, 1.5, 1.5, 1, 1, 0.5],
            'h_sys' => 'p',
            'firdaria' => 'default',
        ],
        'profection' => [
            'asp_orb_all' => [0 => 4, 60 => 2, 90 => 3, 120 => 3, 180 => 3.5, 30 => 0.5, 150 => 1, 45 => 1, 135 => 1, 72 => 0.5, 144 => 0.5],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [3, 2.5, 1, 1, 1, 1.5, 1.5, 1, 1, 0.5],
            'h_sys' => 'p',
        ],
        'synastry' => [
            'asp_orb_all' => [0 => 6, 60 => 4, 90 => 6, 120 => 6, 180 => 6, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100100001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'composite' => [
            'asp_orb_all' => [0 => 4, 60 => 3, 90 => 4, 120 => 4, 180 => 4, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'composite_thirdprogressed' => [
            'asp_orb_all' => [0 => 5, 60 => 4, 90 => 5, 120 => 5, 180 => 5, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'composite_progressions' => [
            'asp_orb_all' => [0 => 4, 60 => 3, 90 => 4, 120 => 4, 180 => 4, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'davison' => [
            'asp_orb_all' => [0 => 6, 60 => 5, 90 => 6, 120 => 6, 180 => 6, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'marks' => [
            'asp_orb_all' => [0 => 6, 60 => 5, 90 => 6, 120 => 6, 180 => 6, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'divination' => [
            'asp_orb_all' => [0 => 4, 60 => 2, 90 => 3, 120 => 3, 180 => 3.5, 30 => 0.5, 150 => 1, 45 => 1, 135 => 1, 72 => 0.5, 144 => 0.5],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111100000001001',
            'planet_orb_all' => [3, 2.5, 1, 1, 1, 1.5, 1.5, 1, 1, 0.5],
            'h_sys' => 'p',
        ],
    ];
    public $setting3 = [
        'now' => [
            'asp_orb_all' => [0 => 7, 60 => 5, 90 => 6, 120 => 6, 180 => 6, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180, 30, 150],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'natal' => [
            'asp_orb_all' => [0 => 7, 60 => 5, 90 => 6, 120 => 6, 180 => 6, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180, 30, 150],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'transits' => [
            'asp_orb_all' => [0 => 2, 60 => 1, 90 => 2, 120 => 2, 180 => 2, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'thirdprogressed' => [
            'asp_orb_all' => [0 => 3, 60 => 2, 90 => 3, 120 => 3, 180 => 3, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'thirdprogressedvsnatal' => [
            'asp_orb_all' => [0 => 3, 60 => 2, 90 => 3, 120 => 3, 180 => 3, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'progressions' => [
            'asp_orb_all' => [0 => 2, 60 => 2, 90 => 2, 120 => 2, 180 => 2, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'progressionsvsnatal' => [
            'asp_orb_all' => [0 => 2, 60 => 2, 90 => 2, 120 => 2, 180 => 2, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'solar' => [
            'asp_orb_all' => [0 => 1, 60 => 0, 90 => 1, 120 => 0, 180 => 1, 30 => 0, 150 => 1, 45 => 1, 135 => 1, 72 => 0, 144 => 0],
            'asps_display' => [0, 45, 90, 135, 180],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'solar_return' => [
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'lunar_return' => [
            'asp_orb_all' => [0 => 4, 60 => 2, 90 => 3, 120 => 3, 180 => 3.5, 30 => 0.5, 150 => 1, 45 => 1, 135 => 1, 72 => 0.5, 144 => 0.5],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'firdaria' => [
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
            'style' => 'cn',
            'firdaria' => 'default',
        ],
        'profection' => [
            'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'synastry' => [
            'asp_orb_all' => [0 => 6, 60 => 4, 90 => 6, 120 => 6, 180 => 6, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'composite' => [
            'asp_orb_all' => [0 => 4, 60 => 3, 90 => 4, 120 => 4, 180 => 4, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'composite_thirdprogressed' => [
            'asp_orb_all' => [0 => 5, 60 => 4, 90 => 5, 120 => 5, 180 => 5, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'composite_progressions' => [
            'asp_orb_all' => [0 => 4, 60 => 3, 90 => 4, 120 => 4, 180 => 4, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'davison' => [
            'asp_orb_all' => [0 => 6, 60 => 5, 90 => 6, 120 => 6, 180 => 6, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'marks' => [
            'asp_orb_all' => [0 => 6, 60 => 5, 90 => 6, 120 => 6, 180 => 6, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
        'divination' => [
            'asp_orb_all' => [0 => 7, 60 => 5, 90 => 6, 120 => 6, 180 => 6, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
            'asps_display' => [0, 60, 90, 120, 180, 30, 150],
            'planets_display' => '111111111111111001001',
            'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'h_sys' => 'p',
        ],
    ];


    /**
     * 获取当前使用的星盘配置方案
     * @param bool $is_in
     * @param string $chart
     * @param bool $default
     * @param int $tid
     * @return array|false|\PDOStatement|string|\think\Model|\think\response\Json
     * @throws ApiException
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */
    public function get($is_in = false, $chart = '', $default = false,$tid=0)
    {
        $uid = $this->user['id'];
        $chart = $chart == '' ? htmlspecialchars(input('chart/s')) : $chart;
        $tid = $tid == 0 ? input('tid/d',0) : $tid;

        if (!in_array($chart, $this->charts))
        {
            throw new ApiException('星盘类型不存在');
        }

        $AstroSettingModel = new AstroSetting();

//        //缓存用户自定义星盘配置
        $setting = $AstroSettingModel->get_user_setting(['tid' => $tid, 'uid' => $uid, 'chart' => $chart]);

        if ($default == true || $setting == null || empty($setting))
        {
            if ($tid = 2) $setting = $this->setting2[$chart];
            elseif ($tid = 3) $setting = $this->setting3[$chart];
            else $setting = $this->setting1[$chart];
            return ['value' => $setting];
        }

        if (empty($setting))
        {
            throw new ApiException('获取星盘配置失败');
        }
        // 若为空 触发更新当前所有为null的 TODO [0]未定义数组索引: natal
        if ($setting[$chart] == NULL)
        {
            if ($setting['tid'] == 1) $setting[$chart] = json_encode($this->setting1[$chart]);
            elseif ($setting['tid'] == 2) $setting[$chart] = json_encode($this->setting2[$chart]);
            elseif ($setting['tid'] == 3) $setting[$chart] = json_encode($this->setting3[$chart]);
            if ($setting[$chart]) Db::table('wechat_backup_07_18_14_43_00.app_astro_setting')
                ->where(['uid' => $uid, 'tid' => $setting['tid']])
                ->update([$chart => $setting[$chart]]);
        }
        $setting['value'] = json_decode($setting[$chart], true);
        unset($setting[$chart]);
        // 更新当前配置使用时间
//         Db::table('app_astro_setting')->where('id',$setting['id'])->setField('use_time',time());
        if ($is_in === true) return $setting;// 内部调用 返回
        return show(config('code.success'), '加载成功', $setting);
    }

    /**
     * 更新配置
     * @return mixed
     * @throws ApiException
     */
//    public function set()
//    {
//        $id = input('id/d');
//        $tid = input('tid/d', 1);
//        $uid = $this->user['id'];
//        $chart = htmlspecialchars(input('chart/s'));
//        if (!in_array($chart, $this->charts))
//        {
//            throw new ApiException('星盘类型不存在');
//        }
//        $set = input('chart_value/s');
//
//        $setArr = json_decode($set, true);
//        if (!isset($setArr['asp_orb_all'])
//            || !isset($setArr['asps_display'])
//            || !isset($setArr['planets_display'])
//            || !isset($setArr['planet_orb_all'])
//            || !isset($setArr['h_sys'])
//            || count($setArr['asp_orb_all']) != 11
//            || strlen($setArr['planets_display']) != 21
//            || count($setArr['planet_orb_all']) != 10
//            || strlen($setArr['h_sys']) != 1
//            || substr($setArr['planets_display'], 0, 10) != '1111111111'
//        )
//        {
//            return show(config('code.error'), '参数错误');
//        }
//
//        $data = json_encode($setArr);
//
//        $time = time();
//
//        try
//        {
//            Db::table('app_astro_setting')
//                ->where(['id' => $id, 'uid' => $uid, 'tid' => $tid])
//                ->update([$chart => $data, 'update_time' => $time, 'use_time' => $time]);
//        } catch (\Exception $e)
//        {
//            // 错误信息写入日志
//            \think\Log::write($e->getMessage(), 'astro_set_error', true);
//
//            throw new ApiException('更新失败');
//        }
//
//        $this->rm_cache(['uid'=>$uid,'chart'=>$chart,'tid'=>$tid]);
//
//        return show(config('code.success'), '更新成功');
//    }

    /**
     * 更换要使用的方案
     * @throws ApiException
     */
//    public function used()
//    {
//        $tid = input('tid/d', 1);
//
//        $uid = $this->user['id'];
//
//        try
//        {
//            Db::table('app_astro_setting')->where(['tid' => $tid, 'uid' => $uid])->setField('use_time', time());
//        } catch (\Exception $e)
//        {
//            // 错误信息写入日志
//            \think\Log::write($e->getMessage(), 'astro_used_error', true);
//
//            throw new ApiException('切换失败');
//        }
//
//        return show(config('code.success'), '切换成功');
//    }

    /**
     * 还原当前方案为默认配置
     * 更新时间还原为NULL
     * @throws ApiException
     */
    public function restore()
    {
        $tid = input('tid/d', 1);
        $chart = input('chart');

        $uid = $this->user['id'];

        if ($tid == 1)
        {
            $setting = $this->setting1;
        } elseif ($tid == 2)
        {
            $setting = $this->setting2;
        } elseif ($tid == 3)
        {
            $setting = $this->setting3;
        } else
        {
            return show(config('code.error'), '还原失败');
        }
        $time = time();
        foreach ($setting as $k => $item)
        {
            if (in_array($k, $this->charts)) $setting[$k] = json_encode($item);
        }
        $setting['create_time'] = $time;
        $setting['update_time'] = NULL;

        try
        {
            Db::table('app_astro_setting')->where(['tid' => $tid, 'uid' => $uid])->update([$chart=>$setting[$chart]]);
        } catch (\Exception $e)
        {
            // 错误信息写入日志
            \think\Log::write($e->getMessage(), 'astro_restore_error', true);

            throw new ApiException('还原失败');
        }

        Cache::rm('user_astro_setting_'.$uid.'-'.$chart.'-'.$tid);

        return show(config('code.success'), '还原成功');
    }

    /**
     * 用户配置初始化
     * @throws ApiException
     */
//    public function init($uid = NULL)
//    {
//        if (!$uid)
//        {
//            $uid = $this->user['id'];
//        }
//        $time = time();
//
//        $exist_count = Db::table('app_astro_setting')->where(['uid' => $uid])->count('id');
//
//        if ($exist_count >= 3)
//        {
//            throw new ApiException('初始化已完成');
//        }
//
//        $setting1 = $this->setting1;
//        foreach ($setting1 as $k1 => $item1)
//        {
//            if (in_array($k1, $this->charts)) $setting1[$k1] = json_encode($item1);
//        }
//        $setting1['create_time'] = $time;
////        $setting1['update_time'] = $time;
//        $setting1['use_time'] = $time;
//        $setting1['tid'] = 1;
//        $setting1['uid'] = $uid;
//
//        $setting2 = $this->setting2;
//        foreach ($setting2 as $k2 => $item2)
//        {
//            if (in_array($k2, $this->charts)) $setting2[$k2] = json_encode($item2);
//        }
//        $setting2['create_time'] = $time;
////        $setting2['update_time'] = $time;
//        $setting2['use_time'] = $time;
//        $setting2['tid'] = 2;
//        $setting2['uid'] = $uid;
//
//        $setting3 = $this->setting3;
//        foreach ($setting3 as $k3 => $item3)
//        {
//            if (in_array($k3, $this->charts)) $setting3[$k3] = json_encode($item3);
//        }
//        $setting3['create_time'] = $time;
////        $setting3['update_time'] = $time;
//        $setting3['use_time'] = $time;
//        $setting3['tid'] = 3;
//        $setting3['uid'] = $uid;
//
//        Db::table('app_astro_setting')->insertGetId($setting1);
//        Db::table('app_astro_setting')->insertGetId($setting2);
//        Db::table('app_astro_setting')->insertGetId($setting3);
//    }


    public function rm_cache($map=[])
    {
        $uid = $map['uid'];
        $chart = $map['chart'];
        $tid = $map['tid'];

        Cache::rm('user_astro_setting_'.$uid.'-'.$chart.'-'.$tid);
    }

}
